/*INSERTION_TRADOIL*/
/**********************************************************************************************************************/
/* !Layer           : MCAL                                                                                            */
/* !Component       : PWD                                                                                             */
/* !Description     : Test Code For PWD Component                                                                     */
/*                                                                                                                    */
/* !File            : PWD_C.tpl                                                                                       */
/* !Description     : PWD APIs                                                                                        */
/*                                                                                                                    */
/* !Reference       :                                                                                                 */
/*                                                                                                                    */
/* Coding language  : OIL                                                                                             */
/*                                                                                                                    */
/* COPYRIGHT VALEO all rights reserved                                                                                */
/**********************************************************************************************************************/
/* Dimension Informations
 * %PCMS_HEADER_SUBSTITUTION_START:%
 * The PID has this format: <Product ID>:<Item ID>.<Variant>-<Item Type>;<Revision>
 * %PID:%
 * %PCMS_HEADER_SUBSTITUTION_END:%
 **********************************************************************************************************************/
'/**********************************************************************************************************************/
/* !Layer           : MCAL                                                                                            */
/* !Component       : PWD                                                                                             */
/* !Description     : Code For PWD Component                                                                          */
/*                                                                                                                    */
/* !File            : PWD.c                                                                                           */
/* !Description     : PWD APIs                                                                                        */
/*                                                                                                                    */
/* !Reference       :                                                                                                 */
/*                                                                                                                    */
/* Coding language  : C                                                                                               */
/*                                                                                                                    */
/* COPYRIGHT VALEO all rights reserved                                                                                */
/**********************************************************************************************************************/
/** `Date()': generated by Genecode `Version()'                                                                       */
/**********************************************************************************************************************/

#include "Std_Types.h" 
#include "STD_LIMITS.h"
#include "PWD.h"
#include "PWD_DEF.h"
#include "Icu_17_GtmCcu6.h"
#include "Dio.h"

#define PWD_START_SEC_CODE
#include "PWD_MemMap.h"

`
PWD_CHANNEL AS FunctionalName CONCATE
{
   WHERE (FunctionalName.PWD_ALIAS == "")
   {'
STATIC boolean PWD_bEna_`FunctionalName'_Flag;`
}
   WHERE (FunctionalName.PWD_ALIAS != "")
   {'
STATIC boolean PWD_bEna_`FunctionalName'_Flag;`
}
}'
/**********************************************************************************************************************/
/* !Runnable    : PWD_vidInit                                                                                         */
/* !Trigger     : Reset                                                                                               */
/* !Description : Initializes the PWD data                                                                            */
/*                                                                                                                    */
/* !LastAuthor  : A. Elkhazragy                                                                                       */
/**********************************************************************************************************************/
void PWD_vidInit(void)
{
   PWD_u16UpdateDisable   = 0;
   PWD_bEnableAll         = FALSE;
   `
PWD_CHANNEL AS FunctionalName CONCATE
{
   WHERE (FunctionalName.PWD_ALIAS == "")
   {
'  
   PWD_bEna_`FunctionalName'_Flag             = FALSE;
   PWD_bEna_`FunctionalName'                  = TRUE;
   PWD_udtPer_`FunctionalName'                = 0;
   PWD_udtActiveDuration_`FunctionalName'     = 0;
   PWD_udtDuty_`FunctionalName'               = 0;
   PWD_udtTout_`FunctionalName'               = PWD_kudtTout_`FunctionalName';
`}
   WHERE (FunctionalName.PWD_ALIAS != "")
   {
'  
   PWD_bEna_`FunctionalName'_Flag             = FALSE;
   PWD_bEna_`FunctionalName'                  = TRUE;
   PWD_udtPer_`FunctionalName'                = 0;
   PWD_udtFreq_`FunctionalName'               = 0;
   PWD_udtActiveDuration_`FunctionalName'     = 0;
   PWD_udtDuty_`FunctionalName'               = 0;
   PWD_udtToutRloadVal_`FunctionalName'       = 0;
   PWD_bFirstPerOccured_`FunctionalName'      = FALSE;
   PWD_bCurrentLvlIsActive_`FunctionalName'   = FALSE;
   PWD_udtTout_Desired_`FunctionalName'       = PWD_kudtTout_`FunctionalName';
   PWD_udtTout_`FunctionalName'               = PWD_udtTIMEOUT_TYPE_MAX;
`}
}'
  
}
 
/**********************************************************************************************************************/
/* !Runnable    : PWD_vidActivationManager                                                                            */
/* !Trigger     : Reset, 2ms                                                                                          */
/* !Description : Enables or disables PWD channels                                                                    */
/*                                                                                                                    */
/* !LastAuthor  : A. Elkhazragy                                                                                       */
/**********************************************************************************************************************/
void PWD_vidActivationManager(void)
{
   if (PWD_u16UpdateDisable != 0x55AA)
   {`
PWD_CHANNEL AS FunctionalName CONCATE
{
   WHERE (FunctionalName.PWD_ALIAS == "")
   {
' 
      if ( (PWD_bEna_`FunctionalName' != FALSE) 
         ||(PWD_bEnableAll != FALSE))
      {
         if(PWD_bEna_`FunctionalName'_Flag == FALSE)
         {
            Icu_17_GtmCcu6_StartSignalMeasurement(IcuConf_IcuChannel_`FunctionalName');
            PWD_bEna_`FunctionalName'_Flag = TRUE;
         }
      }
      else
      { 
         if(PWD_bEna_`FunctionalName'_Flag != FALSE)
         {
            Icu_17_GtmCcu6_StopSignalMeasurement(IcuConf_IcuChannel_`FunctionalName');
            PWD_bEna_`FunctionalName'_Flag = FALSE;
         }
      }
`}
   WHERE (FunctionalName.PWD_ALIAS != "")
   {
' 
      if ( (PWD_bEna_`FunctionalName' != FALSE) 
         ||(PWD_bEnableAll != FALSE))
      {
         if(PWD_bEna_`FunctionalName'_Flag  == FALSE)
         {
            Icu_17_GtmCcu6_StartSignalMeasurement(IcuConf_IcuChannel_`FunctionalName');
            PWD_bEna_`FunctionalName'_Flag  = TRUE;
         }
      }
      else
      { 
         if(PWD_bEna_`FunctionalName'_Flag  != FALSE)
         {
            Icu_17_GtmCcu6_StopSignalMeasurement(IcuConf_IcuChannel_`FunctionalName');
            PWD_bEna_`FunctionalName'_Flag  = FALSE;
         }
      }
   `}
}'
   }
}



/**********************************************************************************************************************/
/* !Runnable    : PWD_vidEntry_10ms                                                                                   */
/* !Trigger     : 10ms                                                                                                */
/* !Description :                                                                                                     */
/*                                                                                                                    */
/* !LastAuthor  : A. Elkhazragy                                                                                       */
/**********************************************************************************************************************/
void PWD_vidEntry_10ms(void)
{
   if (PWD_u16UpdateDisable != 0x55AA)
   {   `
PWD_CHANNEL AS FunctionalName CONCATE
{
   WHERE (FunctionalName.PWD_ALIAS == "")
   {
'  
      PWD_udtWriteTimeoutValue(`FunctionalName', PWD_udtTout_`FunctionalName');
`}
   WHERE (FunctionalName.PWD_ALIAS != "")
   {
'  
      PWD_udtWriteTimeoutValue(`FunctionalName', PWD_udtTout_`FunctionalName');
  `}
}'
   }
}

/**********************************************************************************************************************/
/* !Runnable    : PWD_vidEntry_100ms                                                                                  */
/* !Trigger     : 100ms                                                                                                */
/* !Description :                                                                                                     */
/*                                                                                                                    */
/* !LastAuthor  : Doha Yousri                                                                                         */
/**********************************************************************************************************************/
void PWD_vidEntry_100ms(void)
{
   if (PWD_u16UpdateDisable != 0x55AA)
   {   `
PWD_CHANNEL AS FunctionalName CONCATE
{
   WHERE (FunctionalName.PWD_ALIAS == "")
   {
'  
      PWD_vidMainFunction(`FunctionalName');
`}
   WHERE (FunctionalName.PWD_ALIAS != "")
   {
'  
      PWD_vidMainFunction(`FunctionalName');
  `}
}'
   }
}

#define PWD_STOP_SEC_CODE
#include "PWD_MemMap.h" 

/*---------------------------------------------------- end of file ---------------------------------------------------*/
